<%@ page language="java" contentType="text/html; charset=GBK"
	pageEncoding="GBK"%>
<%@ page import="com.lm.survey.model.*"%> 
<%@ page import="java.util.*"%> 
<% 
QuestionItem item = (QuestionItem)request.getAttribute("item");
SingleChoiceTemplate template = (SingleChoiceTemplate)item.getTemplate();
List list = template.getList();
QuestionItemInstance itemInstance = (QuestionItemInstance)request.getAttribute("itemInstance");
%>	
<li id="li_q_item_<%=item.getId()%>" 	>
<% 
if(item.getRequired()==1){
%>
<script>
		all.item_<%=item.getId()%> = {};
		all.item_<%=item.getId()%>.required = true;
		all.item_<%=item.getId()%>.type="select";
		all.item_<%=item.getId()%>.name="item_<%=item.getId()%>";
		all.item_<%=item.getId()%>.id = "q_item_<%=item.getId()%>";
</script>
<% 
}%>
	<label class="desc" id="q_item_<%=item.getId()%>" for="item_<%=item.getId()%>">
		<% 
		if(item.getRequired()==1)out.println("*");
		%>
		<%=item.getContent() %>
			</label>
	<div>
	<input id="item_<%=item.getId()%>_instnce_id" name="item_<%=item.getId()%>_instance_id" type="hidden" value="<%=(itemInstance!=null?itemInstance.getId():-1) %>" />
	
		<select id="item_<%=item.getId()%>" 			name="item_<%=item.getId()%>" 			class="field select medium" 					tabindex="4" > 
			<% 
	GeneralOptionValue gv = null;
	int selectedId = -1 ;
	String comment = "";
	if(itemInstance!=null){
		selectedId = ((ChoiceInstance)itemInstance.getChoices().get(0)).getTemplateId();
		comment = itemInstance.getComment();
	}
	for(int i=0;i<list.size();i++){
		gv = (GeneralOptionValue)list.get(i);
	
	%>			
			<option value="<%=gv.getId()%>" 
				<% 
				if(gv.getId()==selectedId){
					out.println("selected");
				}
		%>
			>
				<%=gv.getValue()%>
			</option>
	<% }%>
					
					</select>
	</div>
</li>